#include "../source/Server.hpp"

void Connected(const PtrConnect&conn){
    //获取原生指针的地址
    DBG_LOG("create connection: %p",conn.get());
}
void ClosedConnection(const PtrConnect&conn){
    //获取原生指针的地址
    DBG_LOG("close connection: %p",conn.get());
}
void Message(const PtrConnect&conn,Buffer*buff){
    DBG_LOG("read message : %s",buff->ReadPositoin());
    buff->ReadMoveOffset(buff->ReadAbleSize());
    std::string str = "hello world";
    conn->Send(str.c_str(),str.size());
}

int main()
{
    TcpServer server(8080);
    server.SetThreadCount(2);
    server.EnableInactiveRelease(10);
    server.SetConnectedCallback(Connected);
    server.SetClosedCallBack(ClosedConnection);
    server.SetMessageCallBack(Message);
    server.Start();
    return 0;
}